package com.crm.service.crm.course.controller;

import com.crm.model.common.dtos.ResponseResult;
import com.crm.model.crm.course.dtos.CourseDto;
import com.crm.model.crm.course.dtos.PageCourseDto;
import com.crm.service.crm.course.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/course")
public class CourseController {
    @Autowired
    private CourseService courseService;

    /**
     * 课程分页查询
     *
     * @param dto
     * @return
     */
    @GetMapping("/list")
    public ResponseResult findCourseIdOrNameOrCrowdOrCreatedTimeOrSubject(PageCourseDto dto) {
        return courseService.findCourseIdOrNameOrCrowdOrCreatedTimeOrSubject(dto);
    }

    /**
     * 创建课程
     *
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult addCourse(@RequestBody CourseDto dto) {
        return courseService.addCourse(dto);
    }

    /**
     * 删除课程
     *
     * @param courseId
     * @return
     */
    @DeleteMapping("/delete")
    public ResponseResult deleteCourse(@RequestParam String courseId) {
        return courseService.deleteCourse(courseId);
    }

    /**
     * 修改课程
     *
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateCourse(@RequestBody CourseDto dto) {
        return courseService.updateCourse(dto);
    }
}
